package com.yn.admin.zy;


import com.yn.common.model.zy.CarBillDO;
import com.yn.common.page.BasePage;
import com.yn.common.request.driver.CarBillQuery;
import com.yn.common.request.driver.CarBillRequest;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.response.driver.CarBillDetailResponse;
import com.yn.common.response.driver.CarBillResponse;
import com.yn.common.response.driver.DriverIncomeResponse;
import com.yn.common.response.sc.BaseResult;
import com.yn.service.service.ICarBillService;
import com.yn.service.zy.model.dto.TCarFleetManageDTO;
import com.yn.service.zy.model.query.TCarFleetManageQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/tcarbillmanage")
@Api(tags = "司机端流水管理接口")
@Slf4j
public class TCarBillController {

    @Autowired
    private ICarBillService carBillService;

    /**
     * 管理端给司机端进行线下转账得流水
     * */
    @PostMapping("/save")
    @ApiOperation(value = "添加司机流水信息")
    public BaseResult<String> save(@RequestBody @Validated CarBillRequest request){
        log.info("流水信息：{}",request);
        carBillService.saveCarBill(request);
        return BaseResult.success();
    }

    /**
     * 分页查看司机流水账单信息
     * */
    @ApiOperation("分页获取司机流水信息")
    @GetMapping("/list-page")
    public BaseResult<BasePage<CarBillResponse>> listPage(CarBillQuery query, PageParamRequest basePage) {
        log.info("流水查询参数：{}", query);
        BasePage<CarBillResponse> convert = carBillService.listPage(query, basePage);

        return BaseResult.success(convert);
    }

    /**
     * 根据流水表id查询司机流水详情
     * */
    @GetMapping("/getDetail")
    @ApiOperation(value = "查询流水详情")
    public BaseResult<CarBillDetailResponse> getDetail(@RequestParam @Validated Long id){
        log.info("流水id：{}",id);
        return BaseResult.success( carBillService.getDetailById(id));
    }
    /**
     * 根据车队id查询某个车队的流水信息
     * */
    @GetMapping("/fleetBill/{fleetId}")
    @ApiOperation(value = "查询车队流水详情")
    public BaseResult<DriverIncomeResponse> getFleetBill(@PathVariable Integer fleetId){
        log.info("车队id：{}",fleetId);
        return BaseResult.success(carBillService.getFleetBill(fleetId));
    }


}
